package com.example.maggie.meizinote.app;

import android.content.Context;
import android.content.SharedPreferences;

import com.example.maggie.meizinote.R;
import com.iflytek.cloud.SpeechUtility;
import com.jess.arms.base.BaseApplication;

import cn.bmob.v3.Bmob;
import cn.bmob.v3.BmobUser;

/**
 * Created by addis on 2018/4/20.
 */
public class MApp extends BaseApplication {
    private static String AppID = "1dd38a77da2ebe5df3e53c74bf97210e";
    private static Context mContext;
    private static final String userId = "user_id";
    private static final String userEmai = "email";
    public static boolean isNight = false;

    public static void setUserId(BmobUser user) {
        SharedPreferences sp = mContext.getSharedPreferences("us", MODE_PRIVATE);
        sp.edit()
                .putString(userId, user.getObjectId())
                .putString(userEmai, user.getEmail())
                .apply();
    }

    public static String getEmail() {
        SharedPreferences sp = mContext.getSharedPreferences("us", MODE_PRIVATE);
        return sp.getString(userEmai, "");
    }

    public static String getUserId() {
        SharedPreferences sp = mContext.getSharedPreferences("us", MODE_PRIVATE);
        return sp.getString(userId, "");
    }

    @Override
    public void onCreate() {
        super.onCreate();
        mContext = this;
        SpeechUtility.createUtility(this, "appid=58d0e90b");//初始化讯飞
        Bmob.initialize(this, AppID);//初始化bmob
    }
}
